package com.coderush.admin.sys.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.coderush.admin.core.common.PageResult;
import com.coderush.admin.core.component.RedisClient;
import com.coderush.admin.sys.mapper.CompanyMapper;
import com.coderush.admin.sys.model.entity.Company;
import com.coderush.admin.sys.model.vo.CompanyPageVo;
import com.coderush.admin.sys.model.vo.CompanySimpleVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * PackageName com.stellarforce.admin.sys.dao
 *
 * @Author Eason
 * @Version v1.0
 * @ClassName CompanyDao
 * @Date 2025/8/17
 * @Description TODO
 */
@Repository
public class CompanyDao {

    @Resource
    private RedisClient redisClient;
    @Resource
    private CompanyMapper companyMapper;

    /**
     * 根据ID查询可用的公司信息
     */
    public Company getCompanyWithStatus(Long id) {
        return companyMapper.getCompanyWithStatus(id);
    }

    /**
     * 分页查询
     */
    public Page<Company> findByPage(Page<Company> page, String companyName) {
        return companyMapper.findByPage(page, companyName);
    }

    /**
     * 根据公司编码查询
     */
    public Company getCompanyByCode(String companyCode) {
        return companyMapper.getCompanyByCode(companyCode);
    }

    /**
     * 修改公司信息
     */
    public int updateCompany(Company company) {
        return companyMapper.updateById(company);
    }

    /**
     * 添加公司
     * @param company
     * @return
     */
    public int addCompany(Company company) {
        return companyMapper.insert(company);
    }

    /**
     * 根据公司名称查询
     */
    public Company getCompanyByName(String companyName) {
        return companyMapper.getCompanyByName(companyName);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    public Company getById(Long id) {
        return companyMapper.selectById(id);
    }

    /**
     * 查询所有公司
     *
     * @return
     */
    public List<CompanySimpleVo> findAllCompanyList() {
        return companyMapper.findAllCompanyList();
    }

    /**
     * 查询公司列表
     *
     * @param companyId
     * @return
     */
    public List<CompanySimpleVo> findCompanyList(Long companyId) {
        return companyMapper.findCompanyList(companyId);
    }
}